#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
const int N = 6e5 + 10, M = N * 25; 

int n, m;
int s[N];
int tr[M][2], max_id[M];
int root[N], idx;

void insert(int i, int k, int p, int q){
    if(k < 0){
        max_id[q] = i;
        return;
    }

    int v = s[i] >> k & 1;
    if(p) tr[q][v ^ 1] = tr[p][v ^ 1];

    tr[q][v] = ++idx;
    insert(i, k - 1, tr[p][v], tr[q][v]);
    max_id[q] = max(max_id[tr[q][0]], max_id[tr[q][1]]);
}

int query(int root, int c, int l){
    int p = root;
    for(int i = 23; i >= 0; i --){
        int v = c >> i & 1;
        if(max_id[tr[p][v ^ 1]] >= l) p = tr[p][v ^ 1];
        else p = tr[p][v];
    }

    return c ^ s[max_id[p]];
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    
    scanf("%d%d", &n, &m);
    root[0] = ++idx;
    max_id[0] = -1;

    insert(0 ,23, 0, root[0]);

    for(int i = 1; i <= n; i ++){
        int x;
        scanf("%d", &x);
        s[i] = s[i - 1] ^ x;
        root[i] = ++idx;
        insert(i, 23, root[i - 1], root[i]);
    }


    char op[2];
    int l, r, x;

    while(m --){
        scanf("%s", op);
        if(*op == 'A'){
            scanf("%d", &x);
            n ++;
            s[n] = s[n - 1] ^ x;
            root[n] = ++idx;
            insert(n, 23, root[n - 1], root[n]);
        }else{
            scanf("%d%d%d", &l, &r, &x);
            int v = s[n] ^ x;
            printf("%d\n", query(root[r - 1], v, l - 1));
        }
    }



    return 0;
}